#pragma once
#include"RBTree.h"
namespace ljw
{
	template<class K, class V>
	class map
	{
		
	public:
		//typedef RBTree_iterator<pair<K, V>> iterator;
		struct MapKeyOft
		{
			K operator()(const pair<K, V>& key)
			{
				return key.first;
			}
		};
		typedef typename RBTree<K, pair<K,V>,MapKeyOft>::iterator iterator;
		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _t.insert(kv);
		}
		V& operator[](K& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key,V()));
			return ret.first->second;
		}
		iterator begin()
		{

			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
	private:
		RBTree<K, pair<K,V>,MapKeyOft> _t;
	};
}
